#delimit;
capture log close;
set more off;
pause on;
clear all;
set scheme plottig;

cap cd "/Users/deandulay/Dropbox/Myanmar_JOP_EGI_replication";
cap cd "C:\Users\ejm5\Dropbox\Myanmar_JOP_EGI_replication";
use  "data\20220606_mbei_panel_working.dta", clear;


/**********************************************************************************************************************/
/*Table E2: Impact of Facilitation on Official Weighted Core Index*/
#delimit;
svy: reg weighted i.year##i.workshop;
outreg2 using "tables\TableE2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1)  symbol(***, **, *, ^) replace;

#delimit;
svy: reg weighted i.year##i.workshop i.capital i.state_region;
outreg2 using "tables\TableE2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg weighted i.year##i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableE2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg weighted i.year##i.workshop  i.state_region literacy surface_area lag if capital==0;
outreg2 using "tables\TableE2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

reg weighted i.year##i.workshop,  cluster(township);
outreg2 using "tables\TableE2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg weighted i.year##i.workshop i.capital , absorb(state_region) cluster(township);
outreg2 using "tables\TableE2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg weighted i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region) cluster(township);
outreg2 using "tables\TableE2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg weighted i.year##i.workshop  literacy surface_area lag if capital==0, absorb(state_region) cluster(township);
outreg2 using "tables\TableE2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;

/**********************************************************************************************************************/
/*Table E3: Robust to Use of Only Survey Data and Only Administrative Data*/

/*MBEI Survey (Columns 1-4)*/
#delimit;
svy: reg MBEI_survey i.year##i.workshop;
outreg2 using "tables\TableE3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1)  symbol(***, **, *, ^) replace;

svy: reg MBEI_survey  i.year##i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableE3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg MBEI_survey  i.year##i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableE3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg MBEI_survey  i.year##i.workshop  i.state_region literacy surface_area lag if capital==0;
outreg2 using "tables\TableE3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
/**********************************************************************************************************************/

/**********************************************************************************************************************/
/*Table E5: Impact of Facilitation on New 2020 Indicators*/

#delimit;
svy: reg unweighted_NEW i.workshop;
outreg2 using "tables\TableE5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1)  symbol(***, **, *, ^) replace;

#delimit;
svy: reg unweighted_NEW i.workshop i.capital i.state_region;
outreg2 using "tables\TableE5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg unweighted_NEW i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableE5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg unweighted_NEW i.workshop  i.state_region literacy surface_area lag if capital==0;
outreg2 using "tables\TableE5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

reg unweighted_NEW i.workshop,  cluster(township);
outreg2 using "tables\TableE5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg unweighted_NEW i.workshop i.capital , absorb(state_region) cluster(township);
outreg2 using "tables\TableE5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg unweighted_NEW i.workshop i.capital literacy surface_area lag, absorb(state_region) cluster(township);
outreg2 using "tables\TableE5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg unweighted_NEW i.workshop  literacy surface_area lag if capital==0, absorb(state_region) cluster(township);
outreg2 using "tables\TableE5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;
/**********************************************************************************************************************/

/******************************************************************************************************************************************************/

/*Table E7 Impact of Facilitation by Subindex: DAO, GAD, Specialized Shared*/
#delimit;

/*DAO*/
svy: reg subindex1_final i.year##i.workshop  i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) replace;
svy: reg subindex3_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
svy: reg subindex5_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

/*GAD*/
svy: reg subindex2_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
svy: reg subindex10_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

/*Shared*/
svy: reg subindex4_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
svy: reg subindex6_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
svy: reg subindex7_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
svy: reg subindex8_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
svy: reg subindex9_final i.year##i.workshop i.capital literacy surface_area lag   i.state_region;
outreg2 using "tables\TableE7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;
/******************************************************************************************************************************************************/



/******************************************************************************************************************************************************/
/*Use Township Level Data Created in 2_SetUp.do*/
use  "data\20220606_mbei_township.dta", clear;
/******************************************************************************************************************************************************/

/**********************************************************************************************************************/
/*Table E4 Analysis at Township Level*/

#delimit;
reg  unweighted_wy1 i.year##i.workshop;
outreg2 using "tables\TableE4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) replace;

areg  unweighted_wy1 i.year##i.workshop i.capital , absorb(state_region);
outreg2 using "tables\TableE4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg  unweighted_wy1 i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableE4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;

areg  unweighted_wy1 i.year##i.workshop literacy surface_area lag if capital==0, absorb(state_region) ;
outreg2 using "tables\TableE4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;
/**********************************************************************************************************************/

/****************************************************************************************************/
/*Table E3: Robust to Use of Only Survey Data and Only Administrative Data*/
/*MBEI Survey (Columns 5-8)*/

#delimit;
reg MBEI_admin i.year##i.workshop;
outreg2 using "tables\TableE3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg MBEI_admin i.year##i.workshop i.capital , absorb(state_region);
outreg2 using "tables\TableE3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg MBEI_admin i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableE3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg MBEI_admin i.year##i.workshop  literacy surface_area lag if capital==0, absorb(state_region);
outreg2 using "tables\TableE3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;

/****************************************************************************************************/
/*Table E6 Impact of Facilitation on New 2020 Indicators (Township Level)*/
#delimit;
reg unweighted_HARD_NEW i.workshop;
outreg2 using "tables\TableE6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) replace;

areg unweighted_HARD_NEW i.workshop i.capital , absorb(state_region);
outreg2 using "tables\TableE6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg unweighted_HARD_NEW i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableE6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg unweighted_HARD_NEW i.workshop  literacy surface_area lag if capital==0, absorb(state_region);
outreg2 using "tables\TableE6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;

/****************************************************************************************************/

/******************************************************************************************************************************************************/
/*Use STATE Data*/
use  "data\20220606_mbei_state.dta", clear;
/******************************************************************************************************************************************************/
/*Figure E1 Share of Townships and Change in Core MBEI*/
#delimit;
reg fd_weighted workshop  surface_area capital;
avplot workshop, mlabcolor(black) mlab(state_region) mlabsize(tiny) mcolor(navy) msymbol(diamond) msize(small) scheme(s1color) lcolor(navy) lpattern(dash) ytitle("Change in Core MBEI (%)|X", size(medium) margin(medium)) xtitle("Share of Townships Treated (%)|X", size(medium) margin(medium));
graph save "figures\FigureE1.gph", replace;
graph export "figures\FigureE1.pdf", as(pdf) replace;















